## BTW

rm(list = ls())

library(tidyverse)

## Get results 

res <- read_rds("data/Results_Main.rds")

## Prep for plotting

res_plot <- res %>%
  filter(str_detect(outcome, "polar")) %>%
  filter(period_numeric == 1) %>%
  filter(str_detect(term, "Decrease")) %>%
  mutate(outcome = dplyr::recode(outcome,
    `polar_bund_diff` = "Country-level party\nsystem mean",
    `polar_land_diff` = "State-level party\nsystem mean",
    `polar_unit_diff` = "Unit-level party\nsystem mean"
  )) %>%
  mutate(ss = str_replace(ss, "05", "00")) %>%
  filter(str_detect(unit, "Federal")) %>%
  filter(str_detect(ss, "Combined")) %>%
  filter(fe %in% c("Year FE", "Covars + Year FE"))

## PD

pd <- position_dodge(0.4)

## Plot

p1 <- ggplot(
  res_plot %>%
    mutate(fe = factor(fe, levels = unique(fe)[c(2, 1)])),
  aes(fe, estimate)
) +
  geom_hline(yintercept = 0, linetype = "dotted") +
  geom_errorbar(
    aes(
      ymin = conf.low90, ymax = conf.high90,
      color = outcome
    ),
    position = pd, width = 0, size = 1
  ) +
  geom_errorbar(
    aes(
      ymin = conf.low, ymax = conf.high,
      color = outcome
    ),
    position = pd, width = 0, size = 0.5
  ) +
  geom_point(
    position = pd,
    aes(
      shape = outcome,
      color = outcome
    ),
    fill = "white",
    size = 3
  ) +
  theme(legend.position = "bottom") +
  theme_bw() +
  xlab("") +
  ylab("Effect of\nnewspaper exit") +
  theme(legend.position = "bottom") +
  scale_color_grey(name = "", end = .60, start = 0) +
  scale_shape_manual(name = "", values = c(19, 15, 17)) +
  theme(
    axis.title.x = element_blank(),
    legend.key.width = unit(1.2, "cm")
  )
p1

